//
//  FTYPersonInfoPort.m
//  RedWine
//
//  Created by Liufangfang on 2017/1/15.
//  Copyright © 2017年 HuiBangKe. All rights reserved.
//

#import "FTYPersonInfoPort.h"

@implementation FTYPersonInfoPort

+ (void)requestModifyPersonInfoKey:(NSString *)personfInfoKey personInfoValue:(id)pInfoValue view:(UIView *)view{

    FTYUser *user = [FTYUser sharedUser];
    [FTYHTTPManager postInfoWithSubUrl:[NSString stringWithFormat:@"/shop/ybkapi.php?act=ybkapi&op=updatememberinfo&member_id=%@&token=%@&%@=%@", user.userID, user.userToken, personfInfoKey, pInfoValue] parameters:nil block:^(id result, NSError *error) {
        if (!error) {
            
            FTYBaseModel *baseModel = [[FTYBaseModel alloc] init];
            baseModel = [FTYBaseModel mj_objectWithKeyValues:result];
            FTYErrorInfoModel *errorInfo = [FTYErrorInfoModel mj_objectWithKeyValues:baseModel.err];
            
            if (0 == errorInfo.errorcode) {
                
                //保存信息
                [[FTYToastView alloc] addTitle:@"修改成功" addView:view];
                if ([personfInfoKey isEqualToString:@"member_name"]) {
                    [[FTYUser sharedUser] setUserName:pInfoValue];
                } else if([personfInfoKey isEqualToString:@"member_sex"]){
                    [[FTYUser sharedUser] setUserSex:pInfoValue];
                }
                [[FTYToastView alloc] addTitle:@"修改成功" addView:view];
            } else {
                [[FTYToastView alloc] addTitle:errorInfo.errorinfo addView:view];
            }
        } else {
            
        }
    }];
}

@end
